#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    mBtnOk = new QPushButton("ok");
    mHBLGlobal = new QHBoxLayout;
    mHBLGlobal->addWidget(mBtnOk);
    ui->centralWidget->setLayout(mHBLGlobal);

    connect(mBtnOk,SIGNAL(clicked()),this,SLOT(onBtnOkClicked()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::onBtnOkClicked()
{
    mDialog = new Dialog();
    connect(mDialog,SIGNAL(rejected()),this,SLOT(onDialogReject()));
    connect(mDialog,SIGNAL(okClicked(QString)),this,SLOT(onDialogOkClicked(QString)));
    mDialog->exec();
}

void MainWindow::onDialogReject()
{
    qDebug() << " dialog rejected ";
}

void MainWindow::onDialogFinished(int result)
{
    qDebug() << " dialog finished result " << result;
}

void MainWindow::onDialogOkClicked(QString str)
{
    qDebug() << " dialog ok clicked  str " << str;
}

